package com.yxh.www.common.util;

import java.util.regex.Pattern;

/**
 * <p>
 *      正则验证工具类
 * </p>
 *
 * @author yangxiaohui
 * @since 2020/5/6
 */
public class RegularVerifyUtil {

    /**
     * 校验IP字符串合法性
     * @param ipStr IP字符串
     */
    public static boolean verifyIP_Str(String ipStr){
        String ipReg = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
                + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
        Pattern ipPattern = Pattern.compile(ipReg);
        return ipPattern.matcher(ipStr).matches();
    }
}
